package cn.buddha.jeres.server.component;

import cn.buddha.jeres.server.model.EsModel;
import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

/**
 * @ClassName EsComponent
 * @Author 友野浩二
 * @Date 2019/12/26 00:57
 * @Description Eureka Server 组件
 * @Version 1.0
 */
@Component
public class EsComponent {

    /**
     * @return java.util.Map<java.lang.String, java.lang.Object>
     * @Author 友野浩二
     * @Description // 添加 Eureka Server 数据模型,并转换为Map
     * @Date 2019/12/26 01:01
     * @Param
     */
    public Map<String, Object> addElement() {
        return JSON.parseObject(JSON.toJSONString(create()), Map.class);
    }

    /**
     * EsModel模型组织
     */
    private EsModel create() {
        EsModel esModel = new EsModel();

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd号 HH:mm:ss.SSS");
        String currentTime = simpleDateFormat.format(new Date());

        esModel.setCurrentTime(currentTime);
        esModel.setDatacenter("ZhangTong");

        return esModel;
    }

}
